home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performDynamicsClipEffects.m < prev    next >
Encoding:
Text File  |  2003-07-17  |  38.2 KB  |  1,319 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  July, 1998
  22. //  Author:         Carol Levy
  23. //
  24. //  Description:
  25. //      This script contains code to create clip effects for FX.
  26. //        performDynamicsClipEffects is called when a user selects
  27. //      a Dynamics Clip Effects menu item, or selects the "Create"
  28. //      button in a Dynamics Clip Effects option box.
  29. //
  30. //  Input Arguments to performDynamicsClipEffects():
  31. //
  32. //        string $clipEffect  -- the effect selected
  33. //                $flag        0 = execute the command
  34. //                            1 = bring up the option box
  35. //                            2 = dragging to shelf; 
  36. //                                (just return the command string)
  37. //
  38. //  Return Value:
  39. //      None.
  40. //
  41. //
  42. //  ========== createClipEffectsOptions ==========
  43. //
  44. //  SYNOPSIS
  45. //      Create the Dynamics Clip Effects option box and option vars,
  46. //        and set up the appropriate layout for the selected command.
  47. //
  48. global proc int createClipEffectsOptions (string $clipEffect)
  49. {
  50.     string $layout = getOptionBox();
  51.  
  52.     if (size($layout) == 0)
  53.         return 0;
  54.  
  55.     setParent $layout;
  56.  
  57.     // Build the window, with a tab layout
  58.     //
  59.     setUITemplate -pushTemplate DefaultTemplate;
  60.     waitCursor -state 1;
  61.  
  62.     tabLayout -scr true -tv false;
  63.     string $parent = `columnLayout -adjustableColumn 1`;
  64.  
  65.     // Create the layout for this option box.
  66.     //
  67.     dynCreateClipEffectsLayout $parent $clipEffect;
  68.  
  69.     waitCursor -state 0;
  70.     setUITemplate -popTemplate;
  71.  
  72.     // Setup the call to set the values of the option box controls based on
  73.     // the current values of the option vars.
  74.     //
  75.     string $setOptionControls = 
  76.             "dynSetClipEffectsOptionControls "+ $clipEffect + " " + $parent;
  77.  
  78.     // Set up the callback that is called when the apply (create) button is
  79.     // selected by the user.
  80.     //
  81.     string $createCallback = 
  82.             "dynApplyClipEffectsCallback " + $clipEffect + " " + $parent;
  83.  
  84.     // This will be used in the call to dynApplyClipEffectsCallback to
  85.     // tell whether to execute the clip effect command.
  86.     //
  87.     int $executeCmd;
  88.  
  89.     // Get/set the standard option box buttons
  90.     //
  91.     string $buttonLab = "Create";
  92.     if( $clipEffect == "DeleteSurfaceFlow" )
  93.         $buttonLab = "Delete";
  94.     string $applyBtn = getOptionBoxApplyBtn();
  95.     $executeCmd = 1;
  96.     button -edit
  97.         -l $buttonLab
  98.         -command ($createCallback +  " " + $executeCmd)
  99.         $applyBtn;
  100.  
  101.     //  'Save' button.
  102.     //
  103.     string $saveBtn = getOptionBoxSaveBtn();
  104.     $executeCmd = 0;
  105.     button -edit
  106.         -command ($createCallback +  " " + $executeCmd + "; hideOptionBox")
  107.         $saveBtn;
  108.  
  109.     // This will be used in the call to dynSetClipEffectsOptionControls to
  110.     // tell whether to set the option vars to their defaults if they
  111.     // already exist.
  112.     //
  113.     int $resetToDefaults;
  114.     $resetToDefaults = 1;
  115.     //  'Reset' button.
  116.     //
  117.     string $resetBtn = getOptionBoxResetBtn();
  118.     button -edit
  119.         -command ($setOptionControls + " " + $resetToDefaults)
  120.         $resetBtn;
  121.  
  122.     // Set the option box title.
  123.     //
  124.     string $optionBoxTitle = "Create " + $clipEffect +" Effect Options";
  125.     if( $clipEffect == "SurfaceFlow" )
  126.         $optionBoxTitle = "Create Surface Flow Effect Options";
  127.     if( $clipEffect == "DeleteSurfaceFlow" )
  128.         $optionBoxTitle = "Delete Surface Flow Effect Options";
  129.  
  130.     //setOptionBoxTitle("Create " + $clipEffect + " Effect Options");
  131.     setOptionBoxTitle( $optionBoxTitle );
  132.  
  133.     //    Customize the 'Help' menu item text.
  134.     //
  135.     switch ($clipEffect) 
  136.     {
  137.         case "Flow":
  138.             setOptionBoxHelpTag( "CreateCurveFlow" );
  139.             break;        
  140.  
  141.         case "Fire":
  142.             setOptionBoxHelpTag( "CreateFire" );
  143.             break;        
  144.  
  145.         case "Fireworks":
  146.             setOptionBoxHelpTag( "CreateFireworks" );
  147.             break;        
  148.  
  149.         case "Lightning":
  150.             setOptionBoxHelpTag( "CreateLightning" );
  151.             break;        
  152.  
  153.         case "Melt":
  154.             setOptionBoxHelpTag( "" );
  155.             break;        
  156.  
  157.         case "Shatter":
  158.             setOptionBoxHelpTag( "CreateShatter" );
  159.             break;        
  160.  
  161.         case "Smoke":
  162.             setOptionBoxHelpTag( "CreateSmoke" );
  163.             break;        
  164.  
  165.         case "SurfaceFlow":
  166.             setOptionBoxHelpTag( "CreateSurfaceFlow" );
  167.             break;        
  168.  
  169.         case "DeleteSurfaceFlow":
  170.             setOptionBoxHelpTag( "DeleteSurfaceFlow" );
  171.             break;        
  172.     }    
  173.  
  174.  
  175.     // Call the setupOptionControls proc to set the values of the option
  176.     // box controls (and the option vars).
  177.     //
  178.     $resetToDefaults = 0;
  179.     eval (($setOptionControls + " " + $resetToDefaults));      
  180.  
  181.     showOptionBox();
  182.  
  183.     return 1;
  184. }
  185.  
  186.  
  187. //  ========== performDynamicsClipEffects ==========
  188. //
  189. //  SYNOPSIS
  190. //        Called when a user selects a Dynamics Effects menu item, or
  191. //        selects the "Create" button in a Dynamics Effects option box.
  192. //
  193. //        Arguments:
  194. //            $clipEffect    clip effect name 
  195. //            $flag        0 = execute the command
  196. //                        1 = bring up the option box
  197. //                        2 = dragging to shelf; just return the command string
  198. //
  199. global proc string performDynamicsClipEffects( string $clipEffect, int $flag)
  200. {    
  201.     string $cmd = "";
  202.  
  203.     if(!isValidClipEffect($clipEffect))
  204.         return $cmd;
  205.  
  206.     if ($flag < 0 || $flag > 2)
  207.         return $cmd;
  208.  
  209.     if ($flag == 1) 
  210.     {
  211.         // Create the options box and set the values of the
  212.         // controls based on the option vars.
  213.         //
  214.         int $created;
  215.         $created = createClipEffectsOptions($clipEffect);
  216.         if (!$created)
  217.             return $cmd;
  218.     }
  219.     else 
  220.     {
  221.         if( $flag == 0 )
  222.         {
  223.             if( !selectionListOk( $clipEffect ) )
  224.             {
  225.                 return $cmd;
  226.             }
  227.         }
  228.         // Create and set the option vars, if they don't exist already.
  229.         //
  230.         dynSetClipEffectsOptionVars($clipEffect, 0);
  231.  
  232.         // Create the command args for the selected command, and
  233.         // issue the command if flag is 0 (0 means the user has
  234.         // issued a command to create an effect; 2 means the user is
  235.         // dragging the current option box settings to the shelf, in
  236.         // case we had to make the command string, but not execute it.
  237.         //
  238.         switch ($clipEffect) 
  239.         {
  240.             case "Smoke":
  241.                 $cmd = setSmokeCmdString();
  242.                 if ($flag == 0)
  243.                     dynExecuteSmokeCommand($cmd);
  244.                 break;        
  245.             case "Fire":
  246.                 $cmd = setFireCmdString();
  247.                 if ($flag == 0)
  248.                     dynExecuteFireCommand($cmd);
  249.                 break;        
  250.             case "Fireworks":
  251.                 $cmd = setFireworksCmdString();
  252.                 if ($flag == 0)
  253.                     dynExecuteFireworksCommand($cmd);
  254.                 break;        
  255.             case "Flow":
  256.                 $cmd = setFlowCmdString();
  257.                 if ($flag == 0)
  258.                     dynExecuteFlowCommand($cmd);
  259.                 break;        
  260.             case "SurfaceFlow":
  261.                 $cmd = setSurfaceFlowCmdString();
  262.                 if ($flag == 0)
  263.                     dynExecuteSurfaceFlowCommand($cmd);
  264.                 break;        
  265.             case "DeleteSurfaceFlow":
  266.                 $cmd = setDeleteSurfaceFlowCmdString();
  267.                 if ($flag == 0)
  268.                     dynExecuteDeleteSurfaceFlowCommand($cmd);
  269.                 break;        
  270.             case "Lightning":
  271.                 $cmd = setLightningCmdString();
  272.                 if ($flag == 0)
  273.                     dynExecuteLightningCommand($cmd);
  274.                 break;        
  275.             case "Melt":
  276.                 $cmd = setMeltCmdString();
  277.                 if ($flag == 0)
  278.                     dynExecuteMeltCommand($cmd);
  279.                 break;        
  280.             case "Shatter":
  281.                 $cmd = setShatterCmdString();
  282.                 if ($flag == 0)
  283.                     dynExecuteShatterCommand($cmd);
  284.                 break;        
  285.         }    
  286.     }
  287.     return $cmd;
  288. }
  289.  
  290.  
  291. //  ============== setSmokeCmdString ==============
  292. //
  293. //  SYNOPSIS
  294. //        Set the command and command args string for the smoke clip effect
  295. //        command.
  296. //
  297. global proc string setSmokeCmdString()
  298. {
  299.  
  300.     string $cmd;
  301.  
  302.     string $particleName = `optionVar -query smokeParticleName`;
  303.     string $emitterName = `optionVar -query smokeEmitterName`;
  304.     string $turbulenceName = `optionVar -query smokeTurbulenceName`;
  305.     string $smokeImageName = `optionVar -query smokeImageName`;
  306.  
  307.     $cmd = "spriteSmoke( ";
  308.  
  309.     $cmd = $cmd + "\"" + $particleName + "\", ";
  310.     $cmd = $cmd + "\"" + $emitterName + "\", ";
  311.     $cmd = $cmd + "\"" + $turbulenceName + "\", ";
  312.  
  313.     $cmd = $cmd + "\"" + $smokeImageName + "\", ";
  314.     $cmd = $cmd + `optionVar -query smokeStartImage` + ", ";
  315.     $cmd = $cmd + `optionVar -query smokeEndImage` + ", ";
  316.     $cmd = $cmd + `optionVar -query smokeCycleImages` + ", ";
  317.  
  318.     $cmd = $cmd + `optionVar -query smokeMinLifespan` + ", ";
  319.     $cmd = $cmd + `optionVar -query smokeMaxLifespan` +", ";
  320.  
  321.     $cmd = $cmd + `optionVar -query smokeThreshold` + ", ";
  322.     $cmd = $cmd + `optionVar -query smokeOpacity` + ", ";
  323.  
  324.     $cmd = $cmd + `optionVar -query smokeUseTurbulence` + " );\n";
  325.  
  326.     $cmd = $cmd + "spriteSmokeSetEmissionAttributes(";
  327.     $cmd = $cmd + "\"" + $emitterName + "\", ";
  328.     $cmd = $cmd + `optionVar -query smokeEmissionRate` + ", ";
  329.     $cmd = $cmd + `optionVar -query smokeEmissionSpread` + ", ";
  330.     $cmd = $cmd + `optionVar -query smokeEmissionSpeed` + ", ";
  331.     $cmd = $cmd + `optionVar -query smokeEmissionDirX` + ", ";
  332.     $cmd = $cmd + `optionVar -query smokeEmissionDirY` + ", ";
  333.     $cmd = $cmd + `optionVar -query smokeEmissionDirZ` + " );\n";
  334.  
  335.     if (`optionVar -query smokeUseTurbulence`)
  336.     {    
  337.         $cmd = $cmd + "spriteSmokeSetTurbulenceAttributes( ";
  338.         $cmd = $cmd + "\"" + $turbulenceName + "\", ";
  339.         $cmd = $cmd + `optionVar -query smokeTurbulenceMagnitude` + ", ";
  340.         $cmd = $cmd + `optionVar -query smokeTurbulenceFrequency` + ", ";
  341.         $cmd = $cmd + `optionVar -query smokeTurbulenceAttenuation` + " );\n";
  342.     }
  343.  
  344.     return $cmd;
  345. }
  346.  
  347.  
  348. //
  349. //  ============== dynExecuteSmokeCommand ==============
  350. //
  351. //  SYNOPSIS
  352. //        Get the values from the option box (from the optionVars) and issue
  353. //        the spriteSmoke command, and the commands to set the emission and
  354. //        turbulence attributes.
  355. //
  356. global proc dynExecuteSmokeCommand(string $cmd)
  357. {
  358.     // Get the attribute values from the option box.
  359.     //
  360.  
  361.     // Image attribute values.
  362.     //
  363.     string $imageName =  `optionVar -query smokeImageName`;
  364.     int $startImage = `optionVar -query smokeStartImage`;
  365.     int $endImage = `optionVar -query smokeEndImage`;
  366.     int $cycleImages = `optionVar -query smokeCycleImages`;
  367.  
  368.     // Smoke particle attribute values
  369.     //
  370.     string $particleName =  `optionVar -query smokeParticleName`;
  371.     float $minLifeSpan = `optionVar -query smokeMinLifespan`;
  372.     float $maxLifeSpan =  `optionVar -query smokeMaxLifespan`;
  373.     float $threshold = `optionVar -query smokeThreshold`;
  374.     float $opacity = `optionVar -query smokeOpacity`;
  375.  
  376.     // Smoke emitter attribute values
  377.     //
  378.     string $emitterName =  `optionVar -query smokeEmitterName`;
  379.     float $rate = `optionVar -query smokeEmissionRate`;
  380.     float $spread = `optionVar -query smokeEmissionSpread`;
  381.     float $speed = `optionVar -query smokeEmissionSpeed`;
  382.     float $directionX = `optionVar -query smokeEmissionDirX`;
  383.     float $directionY = `optionVar -query smokeEmissionDirY`;
  384.     float $directionZ = `optionVar -query smokeEmissionDirZ`;
  385.  
  386.     int $useTurbulence = `optionVar -query smokeUseTurbulence`;
  387.     string $turbulenceName =  `optionVar -query smokeTurbulenceName`;
  388.  
  389.     string $objectNames[];
  390.  
  391.     // Create the sprite smoke effect.
  392.     //
  393.     $objectNames = spriteSmoke($particleName, $emitterName, $turbulenceName,
  394.                                 $imageName, 
  395.                                 $startImage, $endImage, $cycleImages,
  396.                                 $minLifeSpan, $maxLifeSpan,
  397.                                 $threshold, $opacity, $useTurbulence);
  398.  
  399.     //  Set the emission attributes.
  400.     //
  401.     if (size($objectNames) > 0)
  402.     {
  403.         string $emitterName = $objectNames[0];
  404.         if (objExists($emitterName))
  405.         {
  406.             spriteSmokeSetEmissionAttributes(
  407.                                         $emitterName, 
  408.                                         $rate, $spread, $speed,
  409.                                         $directionX, $directionY, $directionZ);
  410.         }
  411.     }
  412.  
  413.     // Set the turbulence attributes, if the user wants a turbulence field.
  414.     //
  415.     if ($useTurbulence && size($objectNames) > 1)
  416.     {
  417.         string $turbulenceName = $objectNames[1];
  418.         if (objExists($turbulenceName))
  419.         {
  420.             float $magnitude = `optionVar -query smokeTurbulenceMagnitude`;
  421.             float $frequency = `optionVar -query smokeTurbulenceFrequency`;
  422.             float $attenuation = `optionVar -query smokeTurbulenceAttenuation`;
  423.             spriteSmokeSetTurbulenceAttributes( 
  424.                                             $turbulenceName,
  425.                                             $magnitude, $frequency,
  426.                                             $attenuation);
  427.         }
  428.     }
  429.     if (size($objectNames) > 0)
  430.     {
  431.         // The command succeeded, so print the command to the script window.
  432.         //
  433.         $cmd = $cmd + "\n";
  434.         print($cmd);
  435.     }
  436. }
  437.  
  438.  
  439. //  ============== setFireCmdString ==============
  440. //
  441. //  SYNOPSIS
  442. //        Set the command and command args string for the fire clip effect
  443. //        command "fireEffect()".
  444. //
  445. //        fireEffect(string $fireParticleName,
  446. //                    string $fireObject,
  447. //                    string $emitterType)
  448. //
  449. global proc string setFireCmdString()
  450. {
  451.     string $cmd;
  452.  
  453.     // Set the arguments for the call to fireEffect().
  454.     //
  455.     $cmd = "fireEffect ";
  456.  
  457.     // Set the arg for the name of the fire particle and fire object.
  458.     //
  459.     string $particleName = `optionVar -query fireParticleName`;
  460.     string $fireObjectName =  `optionVar -query fireObject`;
  461.  
  462.     if (size($particleName) > 0)
  463.         $cmd = $cmd + $particleName + " ";
  464.     else
  465.         $cmd = $cmd + "\"\" ";
  466.  
  467.     if (size($fireObjectName) > 0)
  468.         $cmd = $cmd + $fireObjectName + " ";
  469.     else
  470.         $cmd = $cmd + "\"\" ";
  471.  
  472.     // Set the emitter type
  473.     //
  474.     int $emitterChoice = `optionVar -query  fireEmissionTypeOV`;
  475.  
  476.     string $emitterType;
  477.     if ($emitterChoice == 1)
  478.         $emitterType = "omni";
  479.     else if ($emitterChoice == 2)
  480.         $emitterType = "direction";
  481.     else if ($emitterChoice == 3)
  482.         $emitterType = "surface";
  483.     else if ($emitterChoice == 4)
  484.         $emitterType = "curve";
  485.  
  486.     $cmd  = $cmd + $emitterType + " ";
  487.  
  488.     $cmd = $cmd + "; ";
  489.  
  490.     return $cmd;
  491. }
  492.  
  493.  
  494. //  ============== dynExecuteFireCommand ==============
  495. //
  496. //  SYNOPSIS
  497. //        Issue the fireEffect command, which is sent into the proc in the arg "$cmd".
  498. //        Then get the values from the option box (from the optionVars) for the
  499. //        fire attributes and issue "fireEffectSetFireAttributes()" command.
  500. //
  501. global proc dynExecuteFireCommand(string $cmd)
  502. {
  503.     // Execute the fireEffect() command and print it to the script window.
  504.     //
  505.     string $fireParticleName = evalEcho($cmd);
  506.  
  507.     if ((!size($fireParticleName)) || (!objExists($fireParticleName)))
  508.         return;
  509.     
  510.     // Now build the command string for the call to fireEffectSetFireAttributes().
  511.     // We had to build it after we have the name of the fire particle.
  512.     //
  513.     string $setAttrsCmd = "fireEffectSetFireAttributes ";
  514.  
  515.     $setAttrsCmd = $setAttrsCmd + $fireParticleName + " ";
  516.     $setAttrsCmd = $setAttrsCmd + `optionVar -query fireScale` + " ";
  517.     $setAttrsCmd = $setAttrsCmd + `optionVar -query fireDensity` + " ";
  518.     $setAttrsCmd = $setAttrsCmd + `optionVar -query fireStartRadius` + " ";
  519.     $setAttrsCmd = $setAttrsCmd + `optionVar -query fireEndRadius` + " ";
  520.     $setAttrsCmd = $setAttrsCmd + `optionVar -query fireIntensity` + " ";
  521.     $setAttrsCmd = $setAttrsCmd + `optionVar -query fireSpeed` + " ";
  522.     $setAttrsCmd = $setAttrsCmd + `optionVar -query fireDirectionX` + " ";
  523.     $setAttrsCmd = $setAttrsCmd + `optionVar -query fireDirectionY` + " ";
  524.     $setAttrsCmd = $setAttrsCmd + `optionVar -query fireDirectionZ` + " ";
  525.     $setAttrsCmd = $setAttrsCmd + `optionVar -query fireSpread`  + " ";
  526.     $setAttrsCmd = $setAttrsCmd + `optionVar -query fireTurbulence`  + ";";
  527.  
  528.     // Execute the fireEffectSetFireAttributes() command and print it to the
  529.     // script window.
  530.     //
  531.     evalEcho($setAttrsCmd);
  532. }
  533.  
  534. //  ============== setFlowCmdString ==============
  535. //
  536. //  SYNOPSIS
  537. //        Set the command and command args string for the flow-along-curves 
  538. //        clip effect.
  539. //        command "flowAlongCurves()".
  540. //
  541. //        flowAlongCurves( int $controlSegmentCount, 
  542. //                            int $subSegmentCount, 
  543. //                            int $attachEmitterToCurve, 
  544. //                            float $emitterRate, 
  545. //                            float $randomMotionSpeed, 
  546. //                            float $lifespan, 
  547. //                            float $goalWeight ) 
  548. //
  549. global proc string setFlowCmdString()
  550. {
  551.     string $cmd;
  552.  
  553.     // Set the arguments for the call to meltEffect().
  554.     //
  555.     $cmd = "flowAlongCurves ";
  556.  
  557.     // Set the arg for the name of the flow object.
  558.     //
  559.     string $flowObject = `optionVar -query flowObject`;
  560.  
  561.     $cmd = $cmd + "\"" + $flowObject +  "\" ";
  562.  
  563.     $cmd = $cmd + `optionVar -query flowNumControlSegs` + " ";
  564.     $cmd = $cmd + `optionVar -query flowNumControlSubsegs` + " ";
  565.     $cmd = $cmd + `optionVar -query flowAttachEmitter` + " ";
  566.     $cmd = $cmd + `optionVar -query flowEmitterRate` + " ";
  567.     $cmd = $cmd + `optionVar -query flowRandomMotion` + " ";
  568.     $cmd = $cmd + `optionVar -query flowLifespan` + " ";
  569.     $cmd = $cmd + `optionVar -query flowGoalWeight` + ";";
  570.  
  571.     return $cmd;
  572. }
  573.  
  574.  
  575. //  ============== dynExecuteFlowCommand ==============
  576. //
  577. //  SYNOPSIS
  578. //        Issue the flowAlonCurves command, which is sent into the proc in the
  579. //        arg "$cmd".
  580. //        Then get the values from the option box (from the optionVars) for the
  581. //        other flow attributes and issue "flowSetAttributes()" command.
  582. //
  583. global proc dynExecuteFlowCommand(string $cmd)
  584. {
  585.     // Execute the flowAlongCurves() command and print it to the script window.
  586.     //
  587.     // string $meltParticleName = evalEcho($cmd);
  588.     evalEcho($cmd);
  589.  
  590.     // IF SETTING ADDITIONAL ATTRS FROM OPTION BOX
  591.     // if (!size($flowName) 
  592.     //     return;
  593.     
  594.     // Now build the command string for the call to meltEffectSetAttributes().
  595.     // We had to build it after we have the name of the melt particle.
  596.     //
  597.     // string $setAttrsCmd = "meltEffectSetAttributes ";
  598.  
  599.     //  $setAttrsCmd = $setAttrsCmd + $flowName + " ";
  600.     //  $setAttrsCmd = $setAttrsCmd + `optionVar -query meltSpeed` + " ";
  601.     // etc
  602.     // Execute the meltEffectSetAttributes() command and print it to the
  603.     // script window.
  604.     //
  605.     // evalEcho($setFlowAttrsCmd);
  606. }
  607.  
  608.  
  609. //  ============== setSurfaceFlowCmdString ==============
  610. //
  611. //  SYNOPSIS
  612. //        Set the command and command args string for the flow-along-surface 
  613. //        clip effect.  command "flowAlongSurfaces()".
  614. //
  615. //        flowAlongSurfaces( string $flowName,
  616. //                            int $createParticle,
  617. //                            int $createParticleForEachFlow,
  618. //                            string $type,
  619. //                            int $controlResolution, 
  620. //                            int $subControlResolution, 
  621. //                            int $manipResolution, 
  622. //                            float $goalWeight, 
  623. //                            float $emitterRate, 
  624. //                            float $minAgeRatio, 
  625. //                            float $maxAgeRatio ) 
  626. //
  627. global proc string setSurfaceFlowCmdString()
  628. {
  629.     string $cmd;
  630.  
  631.     // Set the arguments for the call to flowAlongSurface().
  632.     //
  633.     $cmd = "flowAlongSurfaces ";
  634.  
  635.     // Set the arg for the name of the flow object.
  636.     //
  637.     string $flowName = `optionVar -query surfaceFlowObject`;
  638.     $cmd = $cmd + "\"" + $flowName +  "\" ";
  639.  
  640.     // Create particle object check box.
  641.     //
  642.     $cmd = $cmd + `optionVar -query surfaceFlowCreateParticle` + " ";
  643.     $cmd = $cmd + `optionVar -query surfaceFlowParticleLifespan` + " ";
  644.     $cmd = $cmd + `optionVar -query surfaceFlowCreateParticleForEachFlow`+" ";
  645.     
  646.     // Type of control manipulator.
  647.     //
  648.     $cmd = $cmd + "\"" + `optionVar -query surfaceFlowManipType` +  "\" ";
  649.  
  650.     // Resolutions.
  651.     //
  652.     $cmd = $cmd + `optionVar -query surfaceFlowControlResolution` + " ";
  653.     $cmd = $cmd + `optionVar -query surfaceFlowSubControlResolution` + " ";
  654.     $cmd = $cmd + `optionVar -query surfaceFlowManipulatorResolution` + " ";
  655.     $cmd = $cmd + `optionVar -query surfaceFlowGoalWeight` + " ";
  656.     $cmd = $cmd + `optionVar -query surfaceFlowEmitterRate` + " ";
  657.     $cmd = $cmd + `optionVar -query surfaceFlowMinAgeRatio` + " ";
  658.     $cmd = $cmd + `optionVar -query surfaceFlowMaxAgeRatio` + ";";
  659.  
  660.     return $cmd;
  661. }
  662.  
  663.  
  664. //  ============== dynExecuteSurfaceFlowCommand ==============
  665. //
  666. //  SYNOPSIS
  667. //        Issue the flowAlonSurface command, which is sent into the proc in the
  668. //        arg "$cmd".
  669. //        Then get the values from the option box (from the optionVars) for the
  670. //        other flow attributes and issue "flowSetAttributes()" command.
  671. //
  672. global proc dynExecuteSurfaceFlowCommand(string $cmd)
  673. {
  674.     // Execute the flowAlongSurface() command
  675.     // and print it to the script window.
  676.     //
  677.     evalEcho($cmd);
  678. }
  679.  
  680.  
  681. //  ============== setDeleteSurfaceFlowCmdString ==============
  682. //
  683. //  SYNOPSIS
  684. //        Set the command and command args string for deleting surface flow 
  685. //        clip effect.  command "deleteSurfaceFlows()".
  686. //
  687. global proc string setDeleteSurfaceFlowCmdString()
  688. {
  689.     string $cmd;
  690.  
  691.     int $deleteFlow = 1;
  692.  
  693.     int $radioSelected = `optionVar -q deleteSurfaceFlow`;
  694.     int $deleteParticle = `optionVar -q deleteSurfaceFlowParticles`;
  695.     if( $radioSelected != 1 )
  696.         $deleteFlow = 0;
  697.  
  698.     $cmd = "deleteSurfaceFlows ";
  699.     $cmd = $cmd + " " + $deleteFlow + " " + $deleteParticle + ";";
  700.  
  701.     return $cmd;
  702. }
  703.  
  704.  
  705. //  ============== dynExecuteDeleteSurfaceFlowCommand ==============
  706. //
  707. //  SYNOPSIS
  708. //        Issue the deleteSurfaceFlows command, which is sent into the proc
  709. //        in the arg "$cmd".
  710. //        Then get the values from the option box (from the optionVars) for the
  711. //        other flow attributes and issue "deleteSurfaceFlows()" command.
  712. //
  713. global proc dynExecuteDeleteSurfaceFlowCommand(string $cmd)
  714. {
  715.     // Execute the deleteSurfaceFlows() command
  716.     // and print it to the script window.
  717.     //
  718.     evalEcho($cmd);
  719. }
  720.  
  721.  
  722. //  ============== setLightningCmdString ==============
  723. //
  724. //  SYNOPSIS
  725. //        Set the command and command args string for the lightning 
  726. //        clip effect.  command "lightning()".
  727. //
  728. //        lightning( string $lightningGroupName,
  729. //                            int $grouping,
  730. //                            int $creationOption,
  731. //                            int $segmentCount,
  732. //                            float $thickness, 
  733. //                            float $maxSpread, 
  734. //                            float $lightningStart, 
  735. //                            float $lightningEnd,
  736. //                            float $glowIntensity ) 
  737. //
  738. global proc string setLightningCmdString()
  739. {
  740.     string $cmd;
  741.  
  742.     // Set the arguments for the call to lightning().
  743.     //
  744.     $cmd = "lightning ";
  745.  
  746.     // Set the arg for the name of the lightning object.
  747.     //
  748.     string $name = `optionVar -query lightningObject`;
  749.     $cmd = $cmd + "\"" + $name +  "\" ";
  750.  
  751.     $cmd = $cmd + `optionVar -query lightningGrouping` + " ";
  752.     $cmd = $cmd + `optionVar -query lightningCreateOptions` + " ";
  753.     $cmd = $cmd + `optionVar -query lightningCurveSegments`+ " ";
  754.     $cmd = $cmd + `optionVar -query lightningThickness` + " ";
  755.     $cmd = $cmd + `optionVar -query lightningMaxSpread` + " ";
  756.     $cmd = $cmd + `optionVar -query lightningStart` + " ";
  757.     $cmd = $cmd + `optionVar -query lightningEnd` + " ";
  758.     $cmd = $cmd + `optionVar -query lightningGlowIntensity` + ";";
  759.  
  760.     return $cmd;
  761. }
  762.  
  763.  
  764. //  ============== dynExecuteLightningCommand ==============
  765. //
  766. //  SYNOPSIS
  767. //        Issue the lightning command, which is sent into the proc
  768. //        in the arg "$cmd".
  769. //
  770. global proc dynExecuteLightningCommand(string $cmd)
  771. {
  772.     // Execute the lightning() command
  773.     // and print it to the script window.
  774.     //
  775.     evalEcho($cmd);
  776. }
  777.  
  778.  
  779. //  ============== setMeltCmdString ==============
  780. //
  781. //  SYNOPSIS
  782. //        Set the command and command args string for the melt clip effect
  783. //        command "meltEffect()".
  784. //
  785. //        meltEffect(string $meltObject, string $meltOnObject)
  786. //
  787. global proc string setMeltCmdString()
  788. {
  789.     string $cmd;
  790.  
  791.     // Set the arguments for the call to meltEffect().
  792.     //
  793.     $cmd = "meltEffect ";
  794.  
  795.     // Set the arg for the name of the melt object and melt-on object.
  796.     //
  797.     string $meltObject = `optionVar -query meltObject`;
  798.     string $meltOnObject =  `optionVar -query meltOnObject`;
  799.  
  800.     string $selectedList[];
  801.  
  802.     if(size($meltObject) == 0)
  803.     {
  804.         $selectedList = `ls -sl`;
  805.  
  806.         if (size($selectedList) == 0)
  807.         {
  808.             $cmd = $cmd + "\"\" ";
  809.         }
  810.         else
  811.         {
  812.             $meltObject = $selectedList[0];
  813.  
  814.         }
  815.     }
  816.     $cmd = $cmd + $meltObject + " ";
  817.  
  818.     if (size($meltOnObject) > 0)
  819.         $cmd = $cmd + $meltOnObject + " ";
  820.     else
  821.         $cmd = $cmd + "\"\" ";
  822.  
  823.        int $latticeResX = 2;
  824.        int $latticeResY = 2;
  825.        int $latticeResZ = 2;
  826.  
  827.     int $userSetLatticeRes = `optionVar -query meltUseLatticeRes`;
  828.  
  829.     if ((!$userSetLatticeRes) && (size($meltObject) > 0))
  830.     {
  831.            float $bBoxX, $bBoxY, $bBoxZ;
  832.            $bBoxX = `getAttr ($meltObject + ".boundingBoxSizeX")`;
  833.            $bBoxY = `getAttr ($meltObject + ".boundingBoxSizeY")`;
  834.            $bBoxZ = `getAttr ($meltObject + ".boundingBoxSizeZ")`;
  835.     
  836.            // $latticeResX = $bBoxX ; // * 1.5;
  837.            // $latticeResY = $bBoxY ; // * 1.5;
  838.            // $latticeResZ = $bBoxZ ; // * 1.5;
  839.  
  840.            $latticeResX = $bBoxX  / 2;
  841.            $latticeResY = $bBoxY / 2;
  842.            $latticeResZ = $bBoxZ / 2;
  843.  
  844.            if ($latticeResX < 2)
  845.                $latticeResX = 2;
  846.            if ($latticeResY < 2)
  847.                $latticeResY = 2;
  848.            if ($latticeResZ < 2)
  849.                $latticeResZ = 2;
  850.     }
  851.  
  852.     if ($userSetLatticeRes)
  853.     {
  854.         $latticeResX = `optionVar -query meltLatticeResX`;
  855.         $latticeResY = `optionVar -query meltLatticeResY`;
  856.         $latticeResZ = `optionVar -query meltLatticeResZ`;
  857.     }
  858.  
  859.     $cmd = $cmd + $latticeResX + " ";
  860.     $cmd = $cmd + $latticeResY + " ";
  861.     $cmd = $cmd + $latticeResZ + " ";
  862.  
  863.     $cmd = $cmd + ";";
  864.  
  865.     return $cmd;
  866. }
  867.  
  868.  
  869. //  ============== dynExecuteMeltCommand ==============
  870. //
  871. //  SYNOPSIS
  872. //        Issue the meltEffect command, which is sent into the proc in the arg "$cmd".
  873. //        Then get the values from the option box (from the optionVars) for the
  874. //        melt attributes and issue "meltEffectSetAttributes()" command.
  875. //
  876. global proc dynExecuteMeltCommand(string $cmd)
  877. {
  878.     // Execute the meltEffect() command and print it to the script window.
  879.     //
  880.     string $meltParticleName = evalEcho($cmd);
  881.  
  882.     if ((!size($meltParticleName)) || (!objExists($meltParticleName)))
  883.         return;
  884.     
  885.     // Now build the command string for the call to meltEffectSetAttributes().
  886.     // We had to build it after we have the name of the melt particle.
  887.     //
  888.     string $setAttrsCmd = "meltEffectSetAttributes ";
  889.  
  890.     $setAttrsCmd = $setAttrsCmd + $meltParticleName + " ";
  891.     $setAttrsCmd = $setAttrsCmd + `optionVar -query meltSpeed` + " ";
  892.     $setAttrsCmd = $setAttrsCmd + `optionVar -query meltSpread` + " ";
  893.     $setAttrsCmd = $setAttrsCmd + `optionVar -query meltDistortion` + " ";
  894.     $setAttrsCmd = $setAttrsCmd + `optionVar -query meltDirectionX` + " ";
  895.     $setAttrsCmd = $setAttrsCmd + `optionVar -query meltDirectionY` + " ";
  896.     $setAttrsCmd = $setAttrsCmd + `optionVar -query meltDirectionZ` + " ";
  897.  
  898.     // Execute the meltEffectSetAttributes() command and print it to the
  899.     // script window.
  900.     //
  901.     evalEcho($setAttrsCmd);
  902. }
  903.  
  904.  
  905. //  ============== setShatterCmdString ==============
  906. //
  907. //  SYNOPSIS
  908. //        Set the command and command args string for the shatter clip effect
  909. //        command.
  910. //
  911. global proc string setShatterCmdString()
  912. {
  913.     string $cmd;
  914.  
  915.     string $shatterType = `optionVar -query shatterType`;
  916.  
  917.     if ( $shatterType == "shatterSurfaceTab" )
  918.     {
  919.         $cmd = setSurfaceShatterCmdString();
  920.     }
  921.     else if ( $shatterType == "shatterSolidTab" )
  922.     {
  923.         $cmd = setSolidShatterCmdString();
  924.     }
  925.     else if ( $shatterType == "shatterCrackTab" )
  926.     {
  927.         $cmd = setCrackShatterCmdString();
  928.     }
  929.  
  930.     return $cmd;
  931. }
  932.  
  933.  
  934. //  ============== setSurfaceShatterCmdString ==============
  935. //
  936. //  SYNOPSIS
  937. //        Set the command and command args string for the surface shatter clip effect
  938. //        command.
  939. //
  940. global proc string setSurfaceShatterCmdString()
  941. {
  942.     string $cmd;
  943.  
  944.     string $shatterName   = `optionVar -query shatterSurfaceName`;
  945.     int    $shardCount    = `optionVar -query shatterSurfaceShardCount`;
  946.     int    $exactCount    = true;
  947.     int    $triangulate   = `optionVar -query shatterSurfaceTriangulate`;
  948.     int    $smoothing     = `optionVar -query shatterSurfaceSmoothing`;
  949.     float  $extrude       = `optionVar -query shatterSurfaceExtrude`;
  950. //    float  $perturbation  = `optionVar -query shatterSurfaceEdgePerturbation`;
  951.     float  $perturbation  = 0.0;
  952.     int    $seedValue     = `optionVar -query shatterSurfaceSeedValue`;
  953.     int    $original      = `optionVar -query shatterSurfaceOriginal`;
  954.     string $postOperation = `optionVar -query shatterSurfacePostOperation`;
  955.     string $makeRigid     = `optionVar -query shatterSurfaceMakeRigidBody`;
  956.     int    $verbose       = `optionVar -query shatterSurfaceVerbose`;
  957.  
  958.     if ( $original != 4 )
  959.     {
  960.         $makeRigid = 0;
  961.     }
  962.  
  963.     $cmd = "surfaceShatter( ";
  964.  
  965.     $cmd += "\"" +$shatterName + "\", ";
  966.     $cmd += $shardCount + ", ";
  967.     $cmd += $exactCount + ", ";
  968.     $cmd += $smoothing + ", ";
  969.     $cmd += $triangulate + ", ";
  970.     $cmd += $extrude + ", ";
  971.     $cmd += $perturbation + ", ";
  972.     $cmd += $seedValue + ", ";
  973.     $cmd += $original + ", ";
  974.     $cmd +=  "\"" + $postOperation + "\"" + ", ";
  975.     $cmd += $makeRigid + ", ";
  976.     $cmd += $verbose + ");\n";
  977.  
  978.     return $cmd;
  979. }
  980.  
  981.  
  982. //  ============== setSolidShatterCmdString ==============
  983. //
  984. //  SYNOPSIS
  985. //        Set the command and command args string for the solid shatter clip effect
  986. //        command.
  987. //
  988. global proc string setSolidShatterCmdString()
  989. {
  990.     string $cmd;
  991.  
  992.     string $shatterName    = `optionVar -query shatterSolidName`;
  993.     int    $shardCount     = `optionVar -query shatterSolidShardCount`;
  994.     int    $triangulate    = `optionVar -query shatterSolidTriangulate`;
  995.     int    $applyMaterial  = `optionVar -query shatterSolidInteriorMaterial`;
  996.     int    $removeInterior = `optionVar -query shatterSolidRemoveInterior`;
  997.     float  $extrude        = `optionVar -query shatterSolidExtrude`;
  998.     float  $perturbation   = `optionVar -query shatterSolidEdgePerturbation`;
  999.     int    $seedValue      = `optionVar -query shatterSolidSeedValue`;
  1000.     int    $original       = `optionVar -query shatterSolidOriginal`;
  1001.     string $postOperation  = `optionVar -query shatterSolidPostOperation`;
  1002.     string $makeRigid      = `optionVar -query shatterSolidMakeRigidBody`;
  1003.     int    $verbose        = `optionVar -query shatterSolidVerbose`;
  1004.  
  1005.     int $xRes = 20;
  1006.     int $yRes = 20;
  1007.     int $zRes = 40;
  1008.  
  1009.     if ( $original != 4 )
  1010.     {
  1011.         $makeRigid = 0;
  1012.     }
  1013.  
  1014.     $cmd = "solidShatter( ";
  1015.     $cmd += "\"" +$shatterName + "\", ";
  1016.     $cmd += $shardCount + ", ";
  1017.     $cmd += $triangulate + ", ";
  1018.     $cmd += $applyMaterial + ", ";
  1019.     $cmd += $removeInterior + ", ";
  1020.     $cmd += $extrude + ", ";
  1021.     $cmd += $perturbation + ", ";
  1022.     $cmd += $seedValue + ", ";
  1023.     $cmd += $original + ", ";
  1024.     $cmd +=  "\"" + $postOperation + "\"" + ", ";
  1025.     $cmd += $makeRigid + ", ";
  1026.     $cmd += $verbose + ");\n";
  1027.  
  1028.     return $cmd;
  1029. }
  1030.  
  1031.  
  1032. //  ============== setCrackShatterCmdString ==============
  1033. //
  1034. //  SYNOPSIS
  1035. //        Set the command and command args string for the crack shatter clip effect
  1036. //        command.
  1037. //
  1038. global proc string setCrackShatterCmdString()
  1039. {
  1040.     string $cmd;
  1041.  
  1042.     string $shatterName   = `optionVar -query shatterCrackName`;
  1043.     int    $crackCount    = `optionVar -query shatterCrackCount`;
  1044.     int    $crackLength   = `optionVar -query shatterCrackLength`;
  1045.     int    $triangulate   = `optionVar -query shatterCrackTriangulate`;
  1046.     float  $extrude       = `optionVar -query shatterCrackExtrude`;
  1047.     float  $perturbation  = `optionVar -query shatterCrackEdgePerturbation`;
  1048.     int    $seedValue     = `optionVar -query shatterCrackSeedValue`;
  1049.     string $postOperation = `optionVar -query shatterCrackPostOperation`;
  1050.     int    $original      = `optionVar -query shatterCrackOriginal`;
  1051.     string $makeRigid     = `optionVar -query shatterCrackMakeRigidBody`;
  1052.     int    $verbose       = `optionVar -query shatterCrackVerbose`;
  1053.  
  1054.     if ( $original != 4 )
  1055.     {
  1056.         $makeRigid = 0;
  1057.     }
  1058.  
  1059.     $cmd = "crackShatter( ";
  1060.  
  1061.     $cmd += "\"" +$shatterName + "\", ";
  1062.     $cmd += $crackCount + ", ";
  1063.     $cmd += $crackLength + ", ";
  1064.     $cmd += $triangulate + ", ";
  1065.     $cmd += $perturbation + ", ";
  1066.     $cmd += $extrude + ", ";
  1067.     $cmd += $seedValue + ", ";
  1068.     $cmd += $original + ", ";
  1069.     $cmd +=  "\"" + $postOperation + "\"" + ", ";
  1070.     $cmd += $makeRigid + ", ";
  1071.     $cmd += $verbose + ");\n";
  1072.  
  1073.     return $cmd;
  1074. }
  1075.  
  1076.  
  1077. //  ============== dynExecuteShatterCommand ==============
  1078. //
  1079. //  SYNOPSIS
  1080. //        Issue the shatter Effect command, which is sent into the proc in the arg "$cmd".
  1081. //        Then get the values from the option box (from the optionVars) for the
  1082. //        shatter attributes and issue "shatterEffectSetAttributes()" command.
  1083. //
  1084. global proc dynExecuteShatterCommand(string $cmd)
  1085. {
  1086.     // Execute the shatter effect command and print it to the script window.
  1087.     //
  1088.     string $shatterName[] = evalEcho($cmd);
  1089. }
  1090.  
  1091.  
  1092.  
  1093.  
  1094. //  ============== isValidClipEffect ==============
  1095. //
  1096. //  SYNOPSIS
  1097. //        Return whether the specified clip effect is one we handle.
  1098. //
  1099. global proc int isValidClipEffect (string $clipEffect)
  1100. {
  1101.     if ($clipEffect == "Smoke"                || 
  1102.         $clipEffect == "Fire"                ||
  1103.         $clipEffect == "Fireworks"            ||
  1104.         $clipEffect == "Melt"                ||
  1105.         $clipEffect == "Lightning"            ||
  1106.         $clipEffect == "SurfaceFlow"        ||
  1107.         $clipEffect == "DeleteSurfaceFlow"    ||
  1108.         $clipEffect == "Flow"                 ||
  1109.         $clipEffect == "Shatter")
  1110.     {
  1111.         return 1;
  1112.     }
  1113.     else
  1114.     {
  1115.         warning("The clip effect requested does not exist.");
  1116.         return 0;
  1117.     }
  1118. }
  1119.  
  1120.  
  1121. //  ============== selectionListOk ==============
  1122. //
  1123. //  SYNOPSIS
  1124. //        Check whether the selection list is valid for the given clip effect.
  1125. //
  1126. global proc int selectionListOk(string $clipEffect)
  1127. {
  1128.     string $selectionList[] = `ls -sl`;
  1129.  
  1130.     int $isOk = 1;
  1131.  
  1132.     if ($clipEffect == "Smoke")
  1133.     {
  1134.         if (size($selectionList)  > 1) 
  1135.         {
  1136.             warning("For spriteSmoke only one object may be selected to add an emitter to;  spriteSmoke was not created.");
  1137.             $isOk = 0;
  1138.         }
  1139.     }
  1140.     else if ($clipEffect == "Lightning")
  1141.     {
  1142.         if (size($selectionList)  < 2) 
  1143.         {
  1144.             warning("At least two transforms must be selected to create lightning;  lighting was not created.");
  1145.             $isOk = 0;
  1146.         }
  1147.     }
  1148.     else if ($clipEffect == "SurfaceFlow" || $clipEffect == "Flow")
  1149.     {
  1150.         if (size($selectionList)  < 1) 
  1151.         {
  1152.             warning("At least one object must be selected to create flow;  flow was not created.");
  1153.             $isOk = 0;
  1154.         }
  1155.     }
  1156.     else if ($clipEffect == "Shatter")
  1157.     {
  1158.         if (size($selectionList)  < 1) 
  1159.         {
  1160.             warning("At least one object must be selected to create shatter;  shatter was not created.");
  1161.             $isOk = 0;
  1162.         }
  1163.     }
  1164.  
  1165.     return $isOk;
  1166. }
  1167.  
  1168.  
  1169.  
  1170. //  ============== setFireworksCmdString ==============
  1171. //
  1172. //  SYNOPSIS
  1173. //        Set the command and command args string for the fireworks clip effect
  1174. //        command "fireworks(...)".
  1175. //
  1176. //        fireWorks(string $fireworksName)
  1177. //
  1178. global proc string setFireworksCmdString()
  1179. {
  1180.  
  1181.     // The command line:
  1182.     // fireworks <name> 
  1183.     //             <numTrailColors> <numSparksColors> 
  1184.     //             <trailColorCreationProc> <sparksColorCreationProc>
  1185.     //             <numRockets> 
  1186.     //             <launchPosX> <launchPosY> <launchPosZ>
  1187.     //             <burstPosCenterX> <burstPosCenterY> <burstPosCenterZ>
  1188.     //             <burstExtentsX> <burstExtentsY> <burstExtentsZ>
  1189.     //             <firstLaunchFrame> <launchRate> 
  1190.     //             <minFlightTime> <maxFlightTime>
  1191.     //
  1192.     string $cmd;
  1193.  
  1194.     // Set the arguments for the call to fireworks().
  1195.     //
  1196.     $cmd = "fireworks ";
  1197.  
  1198.     // Set the arg for the name of the fireworks
  1199.     //
  1200.     string $fireworksName = `optionVar -query fireworksName`;
  1201.  
  1202.     if (size($fireworksName) > 0)
  1203.         $cmd = $cmd + $fireworksName + " ";
  1204.     else
  1205.         $cmd = $cmd + "\"\" ";
  1206.  
  1207.     int $numTrailColors = `optionVar -query fwTrailNumColors`;
  1208.     int $numSparksColors = `optionVar -query fwSparksNumColors`;
  1209.  
  1210.     $cmd = $cmd + $numTrailColors + " ";
  1211.     $cmd = $cmd + $numSparksColors + " ";
  1212.  
  1213.     // Get the color creation procs, if the user set them.
  1214.     //
  1215.     if (`optionVar -query fwTrailSetUserColor`)
  1216.     {
  1217.         string $colorProc = `optionVar -query fwTrailColorCreationProc`;
  1218.         if (size($colorProc) > 0)
  1219.             $cmd = $cmd + $colorProc + " ";
  1220.         else
  1221.             $cmd = $cmd + "\"\" ";
  1222.     }
  1223.     else
  1224.     {
  1225.         $cmd = $cmd + "\"\" ";
  1226.     }
  1227.  
  1228.     if (`optionVar -query fwSparksSetUserColor`)
  1229.     {
  1230.         string $colorProc = `optionVar -query fwSparksColorCreationProc`;
  1231.         if (size($colorProc) > 0)
  1232.             $cmd = $cmd + $colorProc + " ";
  1233.         else
  1234.             $cmd = $cmd + "\"\" ";
  1235.     }
  1236.     else
  1237.     {
  1238.         $cmd = $cmd + "\"\" ";
  1239.     }
  1240.  
  1241.     $cmd = $cmd + `optionVar -query fwNumRockets` + " ";
  1242.     $cmd = $cmd + `optionVar -query fwLaunchPositionX` + " ";
  1243.     $cmd = $cmd + `optionVar -query fwLaunchPositionY` + " ";
  1244.     $cmd = $cmd + `optionVar -query fwLaunchPositionZ` + " ";
  1245.     $cmd = $cmd + `optionVar -query fwBurstPosCenterX` + " ";
  1246.     $cmd = $cmd + `optionVar -query fwBurstPosCenterY` + " ";
  1247.     $cmd = $cmd + `optionVar -query fwBurstPosCenterZ` + " ";
  1248.     $cmd = $cmd + `optionVar -query fwBurstExtentsX` + " ";
  1249.     $cmd = $cmd + `optionVar -query fwBurstExtentsY` + " ";
  1250.     $cmd = $cmd + `optionVar -query fwBurstExtentsZ` + " ";
  1251.     $cmd = $cmd + `optionVar -query fwFirstLaunchFrame` + " ";
  1252.     $cmd = $cmd + `optionVar -query fwLaunchRate` + " ";
  1253.     $cmd = $cmd + `optionVar -query fwMinFlightTime` + " ";
  1254.     $cmd = $cmd + `optionVar -query fwMaxFlightTime` + " ";
  1255.     $cmd = $cmd + "; ";
  1256.  
  1257.     return $cmd;
  1258. }
  1259.  
  1260.  
  1261. //  ============== dynExecuteFireworksCommand ==============
  1262. //
  1263. //  SYNOPSIS
  1264. //        Issue the fireworks command, which is sent into the proc in the arg "$cmd".
  1265. //        Then get the values from the option box (from the optionVars) for the
  1266. //        fireworks attributes and issue the set attributes commands.
  1267. //
  1268. global proc dynExecuteFireworksCommand(string $cmd)
  1269. {
  1270.     // Execute the fireworks() command and print it to the script window.
  1271.     //
  1272.     string $fireworksGroup = evalEcho($cmd);
  1273.  
  1274.     if ($fireworksGroup == "")
  1275.         return;
  1276.  
  1277.     string $setAttrsCmd = "";
  1278.  
  1279.     // Build and execute the command string for fwSetRocketAttributes().
  1280.     //
  1281.     $setAttrsCmd = "fwSetRocketAttributes " + $fireworksGroup + " ";
  1282.  
  1283.     $setAttrsCmd = $setAttrsCmd + `optionVar -query fwMaxBurstSpeed` + " ";
  1284.     $setAttrsCmd = $setAttrsCmd + `optionVar -query fwSparksColorSpread` + " ";
  1285.  
  1286.     evalEcho($setAttrsCmd);
  1287.  
  1288.  
  1289.     // Build and execute the command string for fwSetTrailAttributes().
  1290.     //
  1291.     $setAttrsCmd = "fwSetTrailAttributes " + $fireworksGroup + " ";
  1292.  
  1293.     $setAttrsCmd = $setAttrsCmd + `optionVar -query fwTrailRate` + " ";
  1294.     $setAttrsCmd = $setAttrsCmd + `optionVar -query fwTrailSpeed` + " ";
  1295.     $setAttrsCmd = $setAttrsCmd + `optionVar -query fwTrailSpread` + " ";
  1296.     $setAttrsCmd = $setAttrsCmd + `optionVar -query fwMinTrailTailSize` + " ";
  1297.     $setAttrsCmd = $setAttrsCmd + `optionVar -query fwMaxTrailTailSize` + " ";
  1298.  
  1299.     $setAttrsCmd = $setAttrsCmd + `optionVar -query fwTrailGlowIntensity` + " ";
  1300.     $setAttrsCmd = $setAttrsCmd + `optionVar -query fwTrailIncanIntensity` + " ";
  1301.     
  1302.     evalEcho($setAttrsCmd);
  1303.  
  1304.     // Build and execute the command string for fwSetSparksAttributes().
  1305.     //
  1306.     $setAttrsCmd = "fwSetSparksAttributes " + $fireworksGroup + " ";
  1307.  
  1308.     $setAttrsCmd = $setAttrsCmd + `optionVar -query fwMinSparksCount` + " ";
  1309.     $setAttrsCmd = $setAttrsCmd + `optionVar -query fwMaxSparksCount` + " ";
  1310.     $setAttrsCmd = $setAttrsCmd + `optionVar -query fwMinSparksTailSize` + " ";
  1311.     $setAttrsCmd = $setAttrsCmd + `optionVar -query fwMaxSparksTailSize` + " ";
  1312.  
  1313.     $setAttrsCmd = $setAttrsCmd + `optionVar -query fwSparksGlowIntensity` + " ";
  1314.     $setAttrsCmd = $setAttrsCmd + `optionVar -query fwSparksIncanIntensity` + " ";
  1315.     
  1316.     evalEcho($setAttrsCmd);
  1317. }
  1318.  
  1319.